using System.Drawing;

namespace AocBossTimer.Timer
{
    public abstract class BossTimer : IBossTimer
    {
        protected int currentTime;

        protected BossTimer()
        {
            Reset();
        }

        #region IBossTimer Members

        public abstract string Name { get; }
        public abstract int StartTimer { get; }
        public abstract int OrangeTimer { get; }
        public abstract int RedTimer { get; }

        public virtual TickResult StartValue
        {
            get { return new TickResult(StartTimer, GetColor(StartTimer)); }
        }

        public TickResult Tick()
        {
            currentTime -= 1;
            if (currentTime == 0)
            {
                currentTime = StartValue.Seconds;
            }
            return new TickResult(currentTime, GetColor(currentTime));
        }

        public void Reset()
        {
            currentTime = StartTimer;
        }

        #endregion

        private Color GetColor(int time)
        {
            if (time <= RedTimer)
            {
                return Color.Red;
            }
            if (time <= OrangeTimer)
            {
                return Color.Orange;
            }
            return Color.Green;
        }
    }
}